package dao;

import com.db.DBConn;

import java.sql.ResultSet;
import java.sql.SQLException;

public class CheckLogin {

    //管理员登录验证
    public Boolean adminCheckLogin(String ano, String password) {

        try {
            //连接数据库
            DBConn db = new DBConn();
            ResultSet rs = db.queryData("select * from admin where ano='" + ano + "' and password='" + password + "'");
            if (rs.next()) {
                return true;
            } else {
                return false;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
            System.out.print("数据验证失败!!");
            return false;
        }
    }

    //学生登录
    public boolean studentCheckLogin(String sno, String password) {
        try {
            //连接数据库
            DBConn db = new DBConn();
            ResultSet rs = db.queryData("select * from student where sno='" + sno + "' and password='" + password + "'");
            if (rs.next()) {
                return true;
            } else {
                return false;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
            System.out.print("数据验证失败!!");
            return false;
        }
    }

    //教师登录
    public boolean teacherCheckLogin(String tno, String password) {
        try {
            //连接数据库
            DBConn db = new DBConn();
            ResultSet rs = db.queryData("select * from teacher where tno='" + tno + "' and password='" + password + "'");
            if (rs.next()) {
                return true;
            } else {
                return false;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
            System.out.print("数据验证失败!!");
            return false;
        }
    }
}
